<?xml version="1.0" encoding="UTF-8"?>

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:rich="http://richfaces.org/rich" xmlns:a4j="http://richfaces.org/a4j">

<h:form>
    <h:panelGrid columns="2" cellpadding="0" cellspacing="0" columnClasses="top,top" id="tblSearchSize" rendered="#{SearchSizeBean.visiblePage==true}">
        <rich:hotKey key="return"
                     handler="#{rich:element('btnSearchBySize')}.click()"
                     selector="#tblSearchSize"/>
        <h:panelGroup>
            <h:panelGrid columns="1" cellpadding="0" cellspacing="5">
                <h:panelGrid columns="2">
                    <h:outputLabel value="#{searchSizeMsg.filterTypeHint}" for="cbFitlerType" styleClass="bold"/>
                    <h:selectOneMenu id="cbFitlerType"
                                     value="#{SearchSizeBean.filterFormsCombo.selectedValue}"
                                     style="width: 400px">
                        <f:selectItems value="#{SearchSizeBean.filterFormsCombo.items}"/>
                        <a4j:support event="onchange"
                                     action="#{SearchSizeBean.addImagePathAndRefresh}"
                                     reRender="dvFilterSearchPane,dvFilterImage,dvFilters"/>
                    </h:selectOneMenu>
                </h:panelGrid>
                <h:panelGrid id="dvFilterSearchPane" cellpadding="0" cellspacing="0" columns="2" style="padding-left: 50px">
            <h:panelGroup>
                    <h:panelGroup style="margin-top: 30px" id="dvAParam"
                                  rendered="#{SearchSizeBean.availableParameters['a']}">
                        <h:panelGrid columns="4">
                            <h:outputLabel value="A" for="tbAParam"/>
                            <h:inputText id="tbAParam" value="#{SearchSizeBean.paramsValues['a']}"/>
                            <h:outputLabel value=" +-" for="cbAParamExt"/>
                            <h:selectOneMenu id="cbAParamExt" value="#{SearchSizeBean.paramsExtValues['a']}"
                                             style="width: 60px">
                                <f:selectItems value="#{SearchSizeBean.paramsExtSelectItems}"/>
                            </h:selectOneMenu>
                        </h:panelGrid>
                    </h:panelGroup>
                    <h:panelGroup style="margin-top: 30px" id="dvBParam"
                                  rendered="#{SearchSizeBean.availableParameters['b']}">
                        <h:panelGrid columns="4">
                            <h:outputLabel value="B" for="tbBParam"/>
                            <h:inputText id="tbBParam" value="#{SearchSizeBean.paramsValues['b']}"/>

                            <h:outputLabel value=" +-" for="cbBParamExt"/>
                            <h:selectOneMenu id="cbBParamExt" value="#{SearchSizeBean.paramsExtValues['b']}"
                                             style="width: 60px">
                                <f:selectItems value="#{SearchSizeBean.paramsExtSelectItems}"/>
                            </h:selectOneMenu>
                        </h:panelGrid>
                    </h:panelGroup>
                    <h:panelGroup style="margin-top: 30px" id="dvCParam"
                                  rendered="#{SearchSizeBean.availableParameters['c']}">
                        <h:panelGrid columns="4">
                            <h:outputLabel value="C" for="tbCParam"/>
                            <h:inputText id="tbCParam" value="#{SearchSizeBean.paramsValues['c']}"/>

                            <h:outputLabel value=" +-" for="cbCParamExt"/>
                            <h:selectOneMenu id="cbCParamExt" value="#{SearchSizeBean.paramsExtValues['c']}"
                                             style="width: 60px">
                                <f:selectItems value="#{SearchSizeBean.paramsExtSelectItems}"/>
                            </h:selectOneMenu>
                        </h:panelGrid>
                    </h:panelGroup>
                    <h:panelGroup style="margin-top: 30px" id="dvDParam"
                                  rendered="#{SearchSizeBean.availableParameters['d']}">
                        <h:panelGrid columns="4">
                            <h:outputLabel value="D" for="tbDParam"/>
                            <h:inputText id="tbDParam" value="#{SearchSizeBean.paramsValues['d']}"/>

                            <h:outputLabel value=" +-" for="cbDParamExt"/>
                            <h:selectOneMenu id="cbDParamExt" value="#{SearchSizeBean.paramsExtValues['d']}"
                                             style="width: 60px">
                                <f:selectItems value="#{SearchSizeBean.paramsExtSelectItems}"/>
                            </h:selectOneMenu>
                        </h:panelGrid>
                    </h:panelGroup>
                    <h:panelGroup style="margin-top: 30px" id="dvEParam"
                                  rendered="#{SearchSizeBean.availableParameters['e']}">
                        <h:panelGrid columns="4">
                            <h:outputLabel value="E" for="tbEParam"/>
                            <h:inputText id="tbEParam" value="#{SearchSizeBean.paramsValues['e']}"/>

                            <h:outputLabel value=" +-" for="cbEParamExt"/>
                            <h:selectOneMenu id="cbEParamExt" value="#{SearchSizeBean.paramsExtValues['e']}"
                                             style="width: 60px">
                                <f:selectItems value="#{SearchSizeBean.paramsExtSelectItems}"/>
                            </h:selectOneMenu>
                        </h:panelGrid>
                    </h:panelGroup>
                    <h:panelGroup style="margin-top: 30px" id="dvFParam"
                                  rendered="#{SearchSizeBean.availableParameters['f']}">
                        <h:panelGrid columns="4">
                            <h:outputLabel value="F" for="tbFParam"/>
                            <h:inputText id="tbFParam" value="#{SearchSizeBean.paramsValues['f']}"/>

                            <h:outputLabel value=" +-" for="cbFParamExt"/>
                            <h:selectOneMenu id="cbFParamExt" value="#{SearchSizeBean.paramsExtValues['f']}"
                                             style="width: 60px">
                                <f:selectItems value="#{SearchSizeBean.paramsExtSelectItems}"/>
                            </h:selectOneMenu>
                        </h:panelGrid>
                    </h:panelGroup>

                    <h:panelGroup style="margin-top: 30px" id="dvGParam"
                                  rendered="#{SearchSizeBean.availableParameters['g']}">
                        <h:panelGrid columns="2">
                            <h:outputLabel value="G"/>
                            <h:selectOneMenu id="cbGParamExt" value="#{SearchSizeBean.gParam}"
                                             style="width: 150px">
                                <f:selectItems value="#{SearchSizeBean.allGParams}"/>
                            </h:selectOneMenu>
                        </h:panelGrid>
                    </h:panelGroup>

                    <h:panelGroup style="margin-top: 30px" id="dvHParam"
                                  rendered="#{SearchSizeBean.availableParameters['h']}">
                        <h:panelGrid columns="4">
                            <h:outputLabel value="H" for="tbHParam"/>
                            <h:inputText id="tbHParam"
                                         value="#{SearchSizeBean.paramsValues['h']}">
                                <f:validator validatorId="NumberValidator"/>
                                <rich:message for="tbHParam"/>
                            </h:inputText>

                            <h:outputLabel value=" +-" for="cbHParamExt"/>
                            <h:selectOneMenu id="cbHParamExt" value="#{SearchSizeBean.paramsExtValues['h']}"
                                             style="width: 60px">
                                <f:selectItems value="#{SearchSizeBean.paramsExtSelectItems}"/>
                            </h:selectOneMenu>
                        </h:panelGrid>
                    </h:panelGroup>
        </h:panelGroup>
                    <h:panelGroup id="dvFilterImage" rendered="#{SearchSizeBean.imageExist==true}">
                        <h:graphicImage value="/../IMAGES/#{SearchSizeBean.imageFilterForm}"/>
                    </h:panelGroup>
                </h:panelGrid>

                <h:panelGroup>
                    <a4j:commandButton id="btnSearchBySize"
                                       value="#{searchSizeMsg.search}"
                                       action="#{SearchSizeBean.searchAction}"
                                       reRender="dvFilters"/>
                </h:panelGroup>
            </h:panelGrid>
        </h:panelGroup>
    </h:panelGrid>
</h:form>

<h:panelGroup id="dvFilters" rendered="#{SearchSizeBean.visiblePage==true}">
    <h:panelGroup id="dvFiltersNotEmpty" rendered="#{not empty SearchSizeBean.filters}">
        <h:form>
            <rich:dataTable id="tblFilters"
                            value="#{SearchSizeBean.filters}"
                            var="filter"
                            columnClasses="grey bold, white, white, white, white, white, white, white, white, white, white"
                            sortMode="single"
                            title="#{searchSizeMsg.filters}"
                            width="100%"
                            rows="25"
                            reRender="dsFiltersTable">
                <f:facet name="header">
                    <rich:columnGroup>
                        <rich:column colspan="11">
                            <h:outputLabel value="#{searchSizeMsg.filters}"/>
                        </rich:column>
                    </rich:columnGroup>
                </f:facet>
                <rich:column sortBy="#{filter.name}">
                    <f:facet name="header">
                        <h:outputLabel value="#{searchSizeMsg.name}" title="#{searchSizeMsg.name}"/>
                    </f:facet>

                    <h:outputLink onclick="showFoto(#{filter.id});return false;">
                        <h:outputText value="#{filter.name}"/>
                    </h:outputLink>
                </rich:column>

                <rich:column sortBy="#{filter.aParam}">
                    <f:facet name="header">
                        <h:outputLabel value="A" title="A"/>
                    </f:facet>
                    <h:outputText value="#{filter.aParam}"/>
                </rich:column>
                <rich:column sortBy="#{filter.bParam}">
                    <f:facet name="header">
                        <h:outputLabel value="B" title="B"/>
                    </f:facet>
                    <h:outputText value="#{filter.bParam}"/>
                </rich:column>
                <rich:column sortBy="#{filter.cParam}">
                    <f:facet name="header">
                        <h:outputLabel value="C" title="C"/>
                    </f:facet>
                    <h:outputText value="#{filter.cParam}"/>
                </rich:column>
                <rich:column sortBy="#{filter.dParam}">
                    <f:facet name="header">
                        <h:outputLabel value="D" title="D"/>
                    </f:facet>
                    <h:outputText value="#{filter.dParam}"/>
                </rich:column>
                <rich:column sortBy="#{filter.eParam}">
                    <f:facet name="header">
                        <h:outputLabel value="E" title="E"/>
                    </f:facet>
                    <h:outputText value="#{filter.eParam}"/>
                </rich:column>
                <rich:column sortBy="#{filter.fParam}">
                    <f:facet name="header">
                        <h:outputLabel value="F" title="F"/>
                    </f:facet>
                    <h:outputText value="#{filter.fParam}"/>
                </rich:column>
                <rich:column sortBy="#{filter.gParam}">
                    <f:facet name="header">
                        <h:outputLabel value="G" title="G"/>
                    </f:facet>
                    <h:outputText value="#{filter.gParam}"/>
                </rich:column>
                <rich:column sortBy="#{filter.hParam}">
                    <f:facet name="header">
                        <h:outputLabel value="H" title="H"/>
                    </f:facet>
                    <h:outputText value="#{filter.hParam}"/>
                </rich:column>
                <rich:column sortBy="#{filter.pbParam}">
                    <f:facet name="header">
                        <h:outputLabel value="#{searchSizeMsg.pb}" title="#{searchSizeMsg.pb}"/>
                    </f:facet>
                    <h:outputText value="#{filter.pbParam}"/>
                </rich:column>
                <rich:column sortBy="#{filter.nrParam}">
                    <f:facet name="header">
                        <h:outputLabel value="#{searchSizeMsg.nr}" title="#{searchSizeMsg.nr}"/>
                    </f:facet>
                    <h:outputText value="#{filter.nrParam}"/>
                </rich:column>

                <f:facet name="footer">
                    <rich:datascroller id="dsFiltersTable"/>
                </f:facet>
            </rich:dataTable>
        </h:form>
    </h:panelGroup>
</h:panelGroup>
<h:panelGrid rendered="#{SearchSizeBean.visiblePage==false}" columns="1">
    <h:form>
        <h:outputText value=""/>
        <h:outputText value="#{searchSizeMsg.nosearch}" style="font-size: 16px; color:red; font-weight: bold"/>
        <h:outputText value=""/>
    </h:form>
</h:panelGrid>
</html>
